/*
 *  memory.c
 *  xD-OS
 *
 *  Created by James Johns on 07/08/2009.
 *  Copyright 2009 xD-Dunce. All rights reserved.
 *
 */

#include "memory.h"

extern dWord end;			// Address of End of kernel.

void initMemory(){

	endAddress = (dWord)&end;						// Record the address of
													// the end of kernel
	
	
	
	
	
	
#ifdef VERBOSE										// Verbose mode only
	newLine();										// Print all details
	printString("End of kernel is at: ");
	printHex(endAddress);
#endif												// end of verbose mode only
	return;
}

void *malloc(dWord size){

	void *newAddress;
	
	newAddress = (void *)endAddress;
	endAddress += size;

#ifdef DEBUG										// Debug mode only
	newLine();										// Print all details
	printString("Allocated memory at address: ");
	printHex((dWord)newAddress);					// Address of allocated memory
	printString(" | of size : ");
	printInt(size);									// Size of allocated memory
#endif
	return newAddress;
}


